class SingletonBase(type):
    _instances = {}

    def __call__(cls, *args, **kwargs):
        if cls not in cls._instances:
            cls._instances[cls] = super().__call__(*args, **kwargs)
        return cls._instances[cls]


class Singleton(metaclass=SingletonBase):
    def __init__(self):
        self.name = "SingletonExample"

    def print_name(self):
        print(self.name)


# 创建 Singleton 的两个实例
instance1 = Singleton()
instance2 = Singleton()

# 通过两个实例调用 print_name 方法
instance1.print_name()  # 输出: SingletonExample
instance2.print_name()  # 输出: SingletonExample

# 检查两个实例是否相同
print(instance1 is instance2)  # 输出: True

'''
SingletonExample
SingletonExample
True
'''